* Code for analyses in "The Great Leveler? Juvenile Arrest, College Attainment, and the Future of American Inequality"
* Contact: Garrett Baker (garrett.baker@duke.edu)


////////////////////////////////////////////////////////////////
/////////// FIGURE 1. PERCENT GRADUATED FROM COLLEGE ///////////
////////////////////////////////////////////////////////////////


****** happens in R















/////////////////////////////////////////////////////////////////
/////////// TABLE 1. MAIN REGRESSION MODELS ///////////
/////////////////////////////////////////////////////////////////



// Load data
clear all
eststo clear
use "filepath/arrest_educ_cleandata.dta"

* Keep cohorts 0 and 9
keep if inlist(cohort_numeric, 0 , 9)


/////// Pooled sample ///////
* Model 1: No controls
reg w4w5_college4yr arrestedbefore_19, vce(robust)
eststo, title("Model 1")


* Model 2: All controls plus MI
use "filepath/arrest_imputed_dataFULL.dta", clear 
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized pcpubassist_stand i.pceduc_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il, vce(robust)
eststo, title("Model 2")





* Model 3: Neighborhood FE
clear
use "filepath/arrest_educ_cleandata.dta"

keep if inlist(cohort_numeric, 0 , 9)


* Model
use "filepath/arrest_imputed_dataFULL.dta", clear 

gen nhood_stand = nhood_code_w1 if cohort_numeric == 9
replace nhood_stand = nhood_code_w3 if cohort_numeric == 0
replace nhood_stand = nhood_code_w1 if cohort_numeric == 0 & nhood_code_w3 == .

mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized pcpubassist_stand i.pceduc_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic w4state_il i.nhood_stand, vce(cluster nhood_stand)
eststo, title("Model 3")

* Model 4: CBPS 
* (happens in R)


/////// Ever-arrested sample ///////

// Load data
clear 
use "filepath/arrest_educ_cleandata.dta"

* Keep cohorts 0 and 9
keep if inlist(cohort_numeric, 0 , 9)

* Model 5: No controls
reg w4w5_college4yr arrested_19_prepost, vce(robust)
eststo, title("Model 5")

* Model 6: Multiple imputation
use "filepath/arrest_imputed_dataEVER.dta", clear 
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrested_19_prepost i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized pcpubassist_stand i.pceduc_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il, vce(robust) 
eststo, title("Model 6")

esttab using "filepath/outcome_tables_lpm.rtf", replace label mtitles b(2) se(2) star(* 0.05 ** 0.01 *** 0.001)












///////////////////////////////////////////////////////////////////////////
/////////// TABLE 2. Models for HS grads and college enrollees ///////////
///////////////////////////////////////////////////////////////////////////


// Load data
clear all
eststo clear

use "filepath/arrest_imputed_dataPOSTSEC.dta", clear 


* Standard model
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il, vce(robust)
eststo, title("Main Model")
regsave using "filepath/conditional_enroll.dta", addlabel(model, Full Sample) ci replace


* High school grads
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if gradhs_w4w5 == 1, vce(robust)
eststo, title("HS Grads")
regsave using "filepath/conditional_enroll.dta", addlabel(model, High School Grads) ci append

* Enrolled in college
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if enrolled_w4w5 == 1, vce(robust)
eststo, title("Enrollees")
regsave using "filepath/conditional_enroll.dta", addlabel(model, College Enrollees) ci append

* Enrolled plus deprivation measures 
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 deprivation1_w4w5 deprivation2_w4w5 i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if enrolled_w4w5 == 1, vce(robust)
eststo, title("Enrollees + Dep")
regsave using "filepath/conditional_enroll.dta", addlabel(model, Enrollees + Dep) ci append


esttab using "filepath/hsgrad_table.rtf", replace label mtitles b(2) se(2) star(* 0.05 ** 0.01 *** 0.001)
























///////////////////////////////////////////////////////////////
/////////// FIGURE 2. HETEROGENEITY BY DEMOGRAPHICS ///////////
///////////////////////////////////////////////////////////////



// Load imputed data
clear all
eststo clear
use "filepath/arrest_imputed_dataFULL.dta", clear 

* Binary immigrant var b/c of convergence issue 
gen pcimmigrant_w1_binary = 1 if pcimmigrant_w1 == 3 
replace pcimmigrant_w1_binary = 0 if inlist(pcimmigrant_w1, 1, 2)

//// RACE
* Black 
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if sp_ethn_aw == 2, vce(robust)
est store black
regsave using "filepath/heterogeneity_plot.dta", addlabel(model, Black) ci replace

* Hispanic
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if sp_ethn_aw == 3, vce(robust)
est store hispanic
regsave using "filepath/heterogeneity_plot.dta", addlabel(model, Hispanic) ci append

* White
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if sp_ethn_aw == 1, vce(robust)
est store white
regsave using "filepath/heterogeneity_plot.dta", addlabel(model, White) ci append

**** TEST DIFFERENCES BETWEEN HISPANIC AND BLACK/WHITE
/*
eststo clear
reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if sp_ethn_aw == 2
est store black

reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if sp_ethn_aw == 3
est store hispanic

reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if sp_ethn_aw == 1
est store white


suest black hispanic white

test [hispanic_mean]arrestedbefore_19 = [black_mean]arrestedbefore_19
test [hispanic_mean]arrestedbefore_19 = [white_mean]arrestedbefore_19
*/

//// GENDER

* Male
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric ib1.sp_ethn_aw cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if sp_male == 1, vce(robust)
regsave using "filepath/heterogeneity_plot.dta", addlabel(model, Male) ci append

* Female
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric ib1.sp_ethn_aw cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if sp_male == 0, vce(robust)
regsave using "filepath/heterogeneity_plot.dta", addlabel(model, Female) ci append




//// COHORT

* C0
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if cohort_numeric == 0, vce(robust)
regsave using "filepath/heterogeneity_plot.dta", addlabel(model, Cohort0) ci append

* C9 
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if cohort_numeric == 9, vce(robust)
regsave using "filepath/heterogeneity_plot.dta", addlabel(model, Cohort9) ci append















//////////////////////////////////////////////////////
/////////// FIGURE 3. HETEROGENEITY BY SES ///////////
//////////////////////////////////////////////////////


// Load imputed data
clear all
eststo clear
use "filepath/arrest_imputed_dataFULL.dta", clear 

* Binary immigrant var b/c of convergence issue 
gen pcimmigrant_w1_binary = 1 if pcimmigrant_w1 == 3 
replace pcimmigrant_w1_binary = 0 if inlist(pcimmigrant_w1, 1, 2)



//// Parent dropout

* Dropout HS
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male ib1.sp_ethn_aw cbc_total_equalized aptitude_equalized pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if pceduc_stand == 0, vce(robust)
regsave using "filepath/heterogeneity_plot2.dta", addlabel(model, PC Dropout HS) ci replace

* Grad HS
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male ib1.sp_ethn_aw cbc_total_equalized aptitude_equalized pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if inlist(pceduc_stand, 1, 2), vce(robust)
regsave using "filepathheterogeneity_plot2.dta", addlabel(model, PC Graduate HS) ci append


//// Public assistance

* Receive public assistance
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male ib1.sp_ethn_aw cbc_total_equalized aptitude_equalized i.pceduc_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if pcpubassist_stand == 1, vce(robust)
regsave using "filepath/heterogeneity_plot2.dta", addlabel(model, Public Assistance) ci append

* Does not receive assistance
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male ib1.sp_ethn_aw cbc_total_equalized aptitude_equalized i.pceduc_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if pcpubassist_stand == 0, vce(robust)
regsave using "filepath/heterogeneity_plot2.dta", addlabel(model, No Public Assistance) ci append




//// Neighborhood SES

* Low
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male ib1.sp_ethn_aw cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 w4state_il if ses_nc_w1 == 1, vce(robust)
est store nhoodses_LOW
regsave using "filepath/heterogeneity_plot2.dta", addlabel(model, Low Nhood SES) ci append

* Medium
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male ib1.sp_ethn_aw cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 w4state_il if ses_nc_w1 == 2, vce(robust)
est store nhoodses_MED
regsave using "filepath/heterogeneity_plot2.dta", addlabel(model, Medium Nhood SES) ci append

* High
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male ib1.sp_ethn_aw cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 w4state_il if ses_nc_w1 == 3, vce(robust)
est store nhoodses_HIGH
regsave using "filepath/heterogeneity_plot2.dta", addlabel(model, High Nhood SES) ci append



*** Test difference between medium and high SES neighborhoods
cap program drop mysuest 
program mysuest, eclass properties(mi)
version 17.0
args model1 model2 
qui `model1'
estimates store est1
qui `model2'
estimates store est2
suest est1 est2
estimates drop est1 est2

ereturn local title "Seemingly unrelated regression"

end

mi estimate (diff: [est1_mean]arrestedbefore_19 - [est2_mean]arrestedbefore_19), nocoef: mysuest "reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male ib1.sp_ethn_aw cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 w4state_il if ses_nc_w1 == 2" "reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male ib1.sp_ethn_aw cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 w4state_il if ses_nc_w1 == 3" // p = 0.073















////////////////////////////////////////////////////////////////////////
/////////// TABLE 3. Additional schooling covariates ///////////////////
////////////////////////////////////////////////////////////////////////


// Load data
clear all
eststo clear
use "filepath/arrest_imputed_dataC9SCHL.dta"




* Original model
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 ib1.sp_ethn_aw sex cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il, vce(robust)
eststo, title("Original Model")

* Add WRAT and grades
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 wratraw_w1 selfreport_grades_w2 ib1.sp_ethn_aw sex cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il, vce(robust)
eststo, title("+ WRAT & grades")

* Add expectations/aspirations and extracurricular 
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 wratraw_w1 selfreport_grades_w2 expect_coll_w2 aspire_coll_w2 schl_xtracurr_binary_w2 nonschl_xtracurr_binary_w2 ib1.sp_ethn_aw sex cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il, vce(robust)
eststo, title("+ Expectations & extracurriculars")


esttab using "filepath/schoolcovariate_tables.rtf", replace label mtitles b(2) se(2) star(* 0.05 ** 0.01 *** 0.001)


















////////////////////////////////////////////////////////////////////////
/////////// TABLE 4. System avoidance mechanisms //////////////////////
////////////////////////////////////////////////////////////////////////

// Load data
clear all
eststo clear
use "filepath/arrest_imputed_dataSURVEILL.dta"


** COLLEGE
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrested19 ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il, vce(robust)
eststo, title("College grad")
regsave using "filepath/system_avoidance.dta", addlabel(model, College) ci replace

** LABOR
mi estimate, post esampvaryok cmdok: reg working_fulltime_w5 arrested19 w4w5_college4yr ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il, vce(robust)
eststo, title("F-T labor")
regsave using "filepath/system_avoidance.dta", addlabel(model, Labor) ci append

** HEALTHCARE
mi estimate, post esampvaryok cmdok: reg hlth8_w5 arrested19 ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il working_fulltime_w5, vce(robust)
eststo, title("Healthcare")
regsave using "filepath/system_avoidance.dta", addlabel(model, Healthcare) ci append

//// note that this is equalized w4/w5 but labor/healthcare are w5 because w4 doesn't distinguish fulltime 
** CIVIC ORGS
mi estimate, post esampvaryok cmdok: reg civic_org_equalized arrested19 ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il, vce(robust)
eststo, title("Civic")
regsave using "filepath/system_avoidance.dta", addlabel(model, Civic/Political) ci append



esttab using "filepath/sysavoid_tables.rtf", replace label mtitles b(2) se(2) star(* 0.05 ** 0.01 *** 0.001)



































////////////////////////////////////////////////////////////////////////
/////////// TABLE 5. Self-report and delinquency ///////////////////
////////////////////////////////////////////////////////////////////////


clear all
eststo clear
use "filepath/arrest_educ_cleandata.dta"


//// Self-reported arrest

* Create arrested before 19 var
gen arrested_sr_19 = 0
replace arrested_sr_19 = 1 if inrange(law7b_w5, 1, 18) // age first arrest before 19
replace arrested_sr_19 = . if law7_w5 == .

* Create delinquency by W2
gen sro_theft_w1w2 = 0
replace sro_theft_w1w2 = 1 if sro_theft_w1 == 1 | sro_theft_w2 == 1
replace sro_theft_w1w2 = . if sro_theft_w1 == . & sro_theft_w2 == .

gen sro_weaponattack_w1w2 = 0
replace sro_weaponattack_w1w2 = 1 if sro_weaponattack_w1 == 1 | sro_weaponattack_w2 == 1
replace sro_weaponattack_w1w2 = . if sro_weaponattack_w1 == . & sro_weaponattack_w2 == .

gen sro_publictroub_w1w2 = 0
replace sro_publictroub_w1w2 = 1 if sro_publictroub_w1 == 1 | sro_publictroub_w2 == 1
replace sro_publictroub_w1w2 = . if sro_publictroub_w1 == . & sro_publictroub_w2 == .

gen sro_propertydam_w1w2 = 0
replace sro_propertydam_w1w2 = 1 if sro_propertydam_w1 == 1 | sro_propertydam_w2 == 1
replace sro_propertydam_w1w2 = . if sro_propertydam_w1 == . & sro_propertydam_w2 == .




// Main tests
* Model 1: 0 & 9 s-r 
reg w4w5_college4yr arrested_sr_19 i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if inlist(cohort_numeric, 0, 9), vce(robust)
eststo, title("0/9 SR main")

* Model 2: 0 & 9 main specification with both s-r and admin
reg w4w5_college4yr arrested_sr_19 arrestedbefore_19 i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if inlist(cohort_numeric, 0, 9), vce(robust)
eststo, title("0/9 SR+admin main")


* Model 3: Cohort 9 s-r 
reg w4w5_college4yr arrested_sr_19 ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if cohort_numeric == 9, vce(robust)
eststo, title("9 SR main")

* Model 4: Cohort 9 s-r w/ delinquency covariates
reg w4w5_college4yr arrested_sr_19 sro_theft_w1w2 sro_hit_w2 sro_propertydam_w1w2 ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if cohort_numeric == 9, vce(robust)
eststo, title("9 SR delinquency")

* Model 5: Cohort 9 admin w/ delinquency covariates
reg w4w5_college4yr arrestedbefore_19 sro_theft_w1w2 sro_hit_w2 sro_propertydam_w1w2 ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if cohort_numeric == 9, vce(robust)
eststo, title("9 admin delinquency")


esttab using "filepath/self_report_tables.rtf", replace label mtitles b(2) se(2) star(* 0.05 ** 0.01 *** 0.001)















//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//////////////////////          //////////////////////
*                      APPENDIX 
//////////////////////          //////////////////////
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////










/////////////////////////////////////////////////////////////////
/////////// TABLE A1. SAMPLE CHARACTERISTICS BY ARREST ///////////
/////////////////////////////////////////////////////////////////

**** Regular control group

// Load data
clear all
use "filepath/arrest_educ_cleandata.dta"

* Keep cohorts 0 and 9 and non-missing outcome
keep if inlist(cohort_numeric, 0 , 9)
keep if w4w5_college4yr !=.

* Create pc dropout vars
gen pc_dropout_hs = .
replace pc_dropout_hs = 1 if pceduc_stand == 0
replace pc_dropout_hs = 0 if inlist(pceduc_stand, 1, 2)

gen pc_graduate_hs = .
replace pc_graduate_hs = 1 if inlist(pceduc_stand, 1, 2)
replace pc_graduate_hs = 0 if pceduc_stand == 0


* Collapse
collapse (sum) black hispanic white male female cohort_0 cohort_9 pc_dropout_hs pc_graduate_hs, by(arrestedbefore_19)
rename (black-pc_graduate_hs) (freq=)
reshape long freq, i(arrestedbefore_19) j(group) string 
drop if arrestedbefore_19 == .


label define order 1 "black" 2 "hispanic" 3 "white" 4 "male" 5 "female" 6 "cohort_0" 7 "cohort_9" 8 "pc_dropout" 9 "pc_grad"
encode group, label(order) gen(order)

// Create final tables
tab order arrestedbefore_19 [fw=freq] if inlist(group, "black", "hispanic", "white"), col 
tab order arrestedbefore_19 [fw=freq] if inlist(group, "male", "female"), col
tab order arrestedbefore_19 [fw=freq] if inlist(group, "cohort_0", "cohort_9"), col
tab order arrestedbefore_19 [fw=freq] if inlist(group, "pc_dropout_hs", "pc_graduate_hs"), col



**** Strategic comparison group
clear all
use "filepath/arrest_educ_cleandata.dta"

* Keep cohorts 0 and 9 and non-missing outcome
keep if inlist(cohort_numeric, 0 , 9)
keep if w4w5_college4yr !=.

* Create pc dropout vars
gen pc_dropout_hs = .
replace pc_dropout_hs = 1 if pceduc_stand == 0
replace pc_dropout_hs = 0 if inlist(pceduc_stand, 1, 2)

gen pc_graduate_hs = .
replace pc_graduate_hs = 1 if inlist(pceduc_stand, 1, 2)
replace pc_graduate_hs = 0 if pceduc_stand == 0



* Collapse
collapse (sum) black hispanic white male female cohort_0 cohort_9 pc_dropout_hs pc_graduate_hs, by(arrested_19_prepost)
rename (black-pc_graduate_hs) (freq=)
reshape long freq, i(arrested_19_prepost) j(group) string 
drop if arrested_19_prepost == .


label define order 1 "black" 2 "hispanic" 3 "white" 4 "male" 5 "female" 6 "cohort_0" 7 "cohort_9"
encode group, label(order) gen(order)

// Create final tables (note the %s here correspond to the control group aka = 0)
tab order arrested_19_prepost [fw=freq] if inlist(group, "black", "hispanic", "white"), col
tab order arrested_19_prepost [fw=freq] if inlist(group, "male", "female"), col
tab order arrested_19_prepost [fw=freq] if inlist(group, "cohort_0", "cohort_9"), col
tab order arrested_19_prepost [fw=freq] if inlist(group, "pc_dropout_hs", "pc_graduate_hs"), col

















////////////////////////////////////////////////////////////
/////////// APPENDIX FIGURE 1: CBPS BALANCE PLOT ///////////
////////////////////////////////////////////////////////////


**** Happens in R




////////////////////////////////////////////////////////////////////////////
/////////// APPENDIX TABLE A2. TABLE 1 WITH COVARIATES DISPLAYED ///////////
////////////////////////////////////////////////////////////////////////////

**** Same as Table 1


////////////////////////////////////////////////////////////////////////////
/////////// APPENDIX TABLE A3. MAIN REGRESSION MODELS W/ WEIGHTS ///////////
////////////////////////////////////////////////////////////////////////////



// Load data
clear all
eststo clear
use "filepath/arrest_educ_cleandata.dta"

* Keep cohorts 0 and 9
keep if inlist(cohort_numeric, 0 , 9)


/////// Pooled sample ///////
* Model 1: No controls
reg w4w5_college4yr arrestedbefore_19 [pweight = w4w5_wgt_trim], vce(robust)
eststo, title("Model 1")


* Model 2: All controls plus MI
use "filepath/arrest_imputed_dataFULL.dta", clear 
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized pcpubassist_stand i.pceduc_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il [pweight = w4w5_wgt_trim], vce(robust)
eststo, title("Model 2")





* Model 3: Neighborhood FE
clear
use "filepath/arrest_imputed_dataFULL.dta", clear 

gen nhood_stand = nhood_code_w1 if cohort_numeric == 9
replace nhood_stand = nhood_code_w3 if cohort_numeric == 0
replace nhood_stand = nhood_code_w1 if cohort_numeric == 0 & nhood_code_w3 == .

mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized pcpubassist_stand i.pceduc_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic w4state_il i.nhood_stand [pweight = w4w5_wgt_trim], vce(cluster nhood_stand)
eststo, title("Model 3")






* Model 4: CBPS 
* (happens in R)




/////// Ever-arrested sample ///////

// Load data
clear 
use "filepath/arrest_educ_cleandata.dta"

* Keep cohorts 0 and 9
keep if inlist(cohort_numeric, 0 , 9)

* Model 5: No controls
reg w4w5_college4yr arrested_19_prepost [pweight = w4w5_wgt_trim], vce(robust)
eststo, title("Model 5")

* Model 6: Multiple imputation
use "filepath/arrest_imputed_dataEVER.dta", clear 
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr arrested_19_prepost i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized pcpubassist_stand i.pceduc_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il [pweight = w4w5_wgt_trim], vce(robust) 
eststo, title("Model 6")

esttab using "filepath/outcome_tables_lpm_wgt.rtf", replace label mtitles b(2) se(2) star(* 0.05 ** 0.01 *** 0.001)





















//////////////////////////////////////////////////////////////////////
/////////// APPENDIX TABLE A4: LOGIT VERSIONS OF MAIN SPEC ///////////
//////////////////////////////////////////////////////////////////////




/// Pooled sample
clear all
use "filepath/arrest_educ_cleandata.dta"

* Keep cohorts 0 and 9
keep if inlist(cohort_numeric, 0 , 9)

eststo clear

* Model 1: No controls
firthlogit w4w5_college4yr arrestedbefore_19
eststo, title("Model 1")

* Model 2: All controls
use "filepath/arrest_imputed_dataFULL.dta", clear 
mi estimate, post esampvaryok cmdok: firthlogit w4w5_college4yr arrestedbefore_19 i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized pcpubassist_stand i.pceduc_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il
eststo, title("Model 2")



* Model 3: Neighborhood FE
clear
use "filepath/arrest_imputed_dataFULL.dta", clear 

gen nhood_stand = nhood_code_w1 if cohort_numeric == 9
replace nhood_stand = nhood_code_w3 if cohort_numeric == 0
replace nhood_stand = nhood_code_w1 if cohort_numeric == 0 & nhood_code_w3 == .

mi estimate, post esampvaryok cmdok: firthlogit w4w5_college4yr arrestedbefore_19 i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized pcpubassist_stand i.pceduc_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic w4state_il i.nhood_stand
eststo, title("Model 3")


* Model 4: CBPS (Happens in R)


/// Ever-arrested sample
** control group: those arrested after 22.5
clear 
use "filepath/arrest_educ_cleandata.dta"

* Keep cohorts 0 and 9
keep if inlist(cohort_numeric, 0 , 9)

* Model 5: No controls
firthlogit w4w5_college4yr arrested_19_prepost
eststo, title("Model 5")

* Model 6: Multiple imputation
use "filepath/arrest_imputed_dataEVER.dta", clear 
mi estimate, post esampvaryok cmdok: firthlogit w4w5_college4yr arrested_19_prepost i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized pcpubassist_stand i.pceduc_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il
eststo, title("Model 6")

esttab using "filepath/outcome_tables_logit.rtf", replace label mtitles b(2) se(2) star(* 0.05 ** 0.01 *** 0.001)
















//////////////////////////////////////////////////////////////////////
/////////// APPENDIX FIGURE A2: HETEROGENEITY FIGURES WITH FIRTH ///////////
//////////////////////////////////////////////////////////////////////


/////////// Make heterogeneity figures with Firth

// Load imputed data
clear all
eststo clear
use "filepath/arrest_imputed_dataFULL.dta", clear 

* Binary immigrant var b/c of convergence issue 
gen pcimmigrant_w1_binary = 1 if pcimmigrant_w1 == 3 
replace pcimmigrant_w1_binary = 0 if inlist(pcimmigrant_w1, 1, 2)

//// RACE
* Black 
mi estimate, post esampvaryok cmdok: firthlogit w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if sp_ethn_aw == 2
est store black
regsave using "filepath/heterogeneity_plot_firth.dta", addlabel(model, Black) ci replace

* Hispanic
mi estimate, post esampvaryok cmdok: firthlogit w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if sp_ethn_aw == 3
est store hispanic
regsave using "filepath/heterogeneity_plot_firth.dta", addlabel(model, Hispanic) ci append

* White
mi estimate, post esampvaryok cmdok: firthlogit w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if sp_ethn_aw == 1
est store white
regsave using "filepath/heterogeneity_plot_firth.dta", addlabel(model, White) ci append


//// GENDER

* Male
mi estimate, post esampvaryok cmdok: firthlogit w4w5_college4yr arrestedbefore_19 i.cohort_numeric ib1.sp_ethn_aw cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if sp_male == 1
regsave using "filepath/heterogeneity_plot_firth.dta", addlabel(model, Male) ci append

* Female
mi estimate, post esampvaryok cmdok: firthlogit w4w5_college4yr arrestedbefore_19 i.cohort_numeric ib1.sp_ethn_aw cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if sp_male == 0
regsave using "filepath/heterogeneity_plot_firth.dta", addlabel(model, Female) ci append




//// COHORT

* C0
mi estimate, post esampvaryok cmdok: firthlogit w4w5_college4yr arrestedbefore_19 ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if cohort_numeric == 0
regsave using "filepath/heterogeneity_plot_firth.dta", addlabel(model, Cohort0) ci append

* C9 
mi estimate, post esampvaryok cmdok: firthlogit w4w5_college4yr arrestedbefore_19 ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if cohort_numeric == 9
regsave using "filepath/heterogeneity_plot_firth.dta", addlabel(model, Cohort9) ci append









//////////////////////////////////////////////////////////////////////
/////////// APPENDIX FIGURE A3: FIRTH 2 SES ///////////
//////////////////////////////////////////////////////////////////////

//////// FIGURE 3 //////

// Load imputed data
clear all
eststo clear
use "filepath/arrest_imputed_dataFULL.dta", clear 

* Binary immigrant var b/c of convergence issue 
gen pcimmigrant_w1_binary = 1 if pcimmigrant_w1 == 3 
replace pcimmigrant_w1_binary = 0 if inlist(pcimmigrant_w1, 1, 2)



//// Parent dropout

* Dropout HS
mi estimate, post esampvaryok cmdok: firthlogit w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male ib1.sp_ethn_aw cbc_total_equalized aptitude_equalized pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if pceduc_stand == 0
regsave using "filepath/heterogeneity_plot2_firth.dta", addlabel(model, PC Dropout HS) ci replace

* Grad HS
mi estimate, post esampvaryok cmdok: firthlogit w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male ib1.sp_ethn_aw cbc_total_equalized aptitude_equalized pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if inlist(pceduc_stand, 1, 2)
regsave using "filepath/heterogeneity_plot2_firth.dta", addlabel(model, PC Graduate HS) ci append


//// Public assistance

* Receive public assistance
mi estimate, post esampvaryok cmdok: firthlogit w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male ib1.sp_ethn_aw cbc_total_equalized aptitude_equalized i.pceduc_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if pcpubassist_stand == 1
regsave using "filepath/heterogeneity_plot2_firth.dta", addlabel(model, Public Assistance) ci append

* Does not receive assistance
mi estimate, post esampvaryok cmdok: firthlogit w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male ib1.sp_ethn_aw cbc_total_equalized aptitude_equalized i.pceduc_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il if pcpubassist_stand == 0
regsave using "filepath/heterogeneity_plot2_firth.dta", addlabel(model, No Public Assistance) ci append




//// Neighborhood SES

* Low
mi estimate, post esampvaryok cmdok: firthlogit w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male ib1.sp_ethn_aw cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 w4state_il if ses_nc_w1 == 1
est store nhoodses_LOW
regsave using "filepath/heterogeneity_plot2_firth.dta", addlabel(model, Low Nhood SES) ci append

* Medium
mi estimate, post esampvaryok cmdok: firthlogit w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male ib1.sp_ethn_aw cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 w4state_il if ses_nc_w1 == 2
est store nhoodses_MED
regsave using "filepath/heterogeneity_plot2_firth.dta", addlabel(model, Medium Nhood SES) ci append

* High
mi estimate, post esampvaryok cmdok: firthlogit w4w5_college4yr arrestedbefore_19 i.cohort_numeric sp_male ib1.sp_ethn_aw cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand pcimmigrant_w1_binary i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 w4state_il if ses_nc_w1 == 3
est store nhoodses_HIGH
regsave using "filepath/heterogeneity_plot2_firth.dta", addlabel(model, High Nhood SES) ci append







//////////////////////////////////////////////////////////////////////
/////////// APPENDIX FIGURE A4: AGE CUTOFF SENSITIVITY ///////////
//////////////////////////////////////////////////////////////////////

// Load data
clear all
use "filepath/arrest_educ_cleandata.dta"

* Keep cohorts 0 and 9
keep if inlist(cohort_numeric, 0 , 9)



* Age 18
reg w4w5_college4yr arrestedbefore_18 i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il, vce(robust)
regsave using "filepath/age_cutoff_figure.dta", addlabel(model, Age18) ci replace
* Age 19 (main model)
reg w4w5_college4yr arrestedbefore_19 i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il, vce(robust)
regsave using "filepath/age_cutoff_figure.dta", addlabel(model, Age19) ci append
* Age 20
reg w4w5_college4yr arrestedbefore_20 i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized i.pceduc_stand pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il, vce(robust)
regsave using "filepath/age_cutoff_figure.dta", addlabel(model, Age20) ci append

















/////////////// FOOTNOTES



////// EVER-ARRESTED UPPER BOUND AGE CUTOFF
// Load data
clear all
eststo clear
use "filepath/arrest_educ_cleandata.dta"

keep if inlist(cohort_numeric, 0 , 9)

// Logit models
logit w4w5_college4yr arrested_19_prepost_23 i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized pc_dropout_w1 pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il

logit w4w5_college4yr arrested_19_prepost_235 i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized pc_dropout_w1 pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il

// LPMs
reg w4w5_college4yr arrested_19_prepost_23 i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized pc_dropout_w1 pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il, vce(robust)

reg w4w5_college4yr arrested_19_prepost_235 i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized pc_dropout_w1 pcpubassist_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il, vce(robust)




///// PREDICTOR BEING NUM OF ARRESTS
// Load MI data
use "filepath/arrest_imputed_dataFULL.dta", clear 

* Model with linear
mi estimate, post esampvaryok cmdok: reg w4w5_college4yr numarrestsbefore_19 i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized pcpubassist_stand i.pceduc_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il, vce(robust)

* Model with poisson
mi estimate, post esampvaryok cmdok: poisson w4w5_college4yr numarrestsbefore_19 i.cohort_numeric ib1.sp_ethn_aw sp_male cbc_total_equalized aptitude_equalized pcpubassist_stand i.pceduc_stand ib3.pcimmigrant_w1 i.pcsingle_stand parent_legal_stand fam_depression_indic fam_medical_indic fam_drugalc_indic fam_genprobs_indic ptceff1 ptebdo1 i.ses_nc_w1 w4state_il, vce(robust)















